home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / term-source.lha / Extras / Source / term-Source.lha / UploadPanel.c < prev    next >
C/C++ Source or Header  |  1995-02-07  |  4KB  |  212 lines

  1. /*
  2. **    UploadPanel.c
  3. **
  4. **    ZModem auto-upload control panel support routines
  5. **
  6. **    Copyright © 1990-1995 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12. BYTE __regargs
  13. UploadPanel(BOOLEAN SendMode)
  14. {
  15.     struct LayoutHandle    *Handle;
  16.     BYTE             Selection = UPLOAD_IGNORE,
  17.                  FromQueue;
  18.  
  19.     if(SendMode)
  20.         FromQueue = CheckUpload();
  21.     else
  22.         FromQueue = FALSE;
  23.  
  24.     if(Handle = LT_CreateHandleTags(Window -> WScreen,
  25.         LH_LocaleHook,    &LocaleHook,
  26.     TAG_DONE))
  27.     {
  28.         struct Window *PanelWindow;
  29.  
  30.         LT_New(Handle,
  31.             LA_Type,    VERTICAL_KIND,
  32.         TAG_DONE);
  33.         {
  34.             LT_New(Handle,
  35.                 LA_Type,    VERTICAL_KIND,
  36.                 LA_LabelID,    MSG_UPLOADPANEL_SELECT_TRANSFER_TYPE_GAD,
  37.             TAG_DONE);
  38.             {
  39.                 LT_New(Handle,
  40.                     LA_Type,    BUTTON_KIND,
  41.                     LA_LabelID,    SendMode ? MSG_UPLOADPANEL_TEXT_UPLOAD_GAD : MSG_UPLOADPANEL_TEXT_DOWNLOAD_GAD,
  42.                     LA_ID,        UPLOAD_TEXT,
  43.                 TAG_DONE);
  44.  
  45.                 LT_New(Handle,
  46.                     LA_Type,    BUTTON_KIND,
  47.                     LA_LabelID,    SendMode ? MSG_UPLOADPANEL_BINARY_UPLOAD_GAD : MSG_UPLOADPANEL_BINARY_DOWNLOAD_GAD,
  48.                     LA_ID,        UPLOAD_BINARY,
  49.                     LABT_ReturnKey,    TRUE,
  50.                 TAG_DONE);
  51.  
  52.                 LT_EndGroup(Handle);
  53.             }
  54.  
  55.             if(SendMode)
  56.             {
  57.                 LT_New(Handle,
  58.                     LA_Type,VERTICAL_KIND,
  59.                 TAG_DONE);
  60.                 {
  61.                     LT_New(Handle,
  62.                         LA_Type,    CHECKBOX_KIND,
  63.                         LA_LabelID,    MSG_UPLOADPANEL_FROM_UPLOAD_QUEUE_TXT,
  64.                         LA_BYTE,    &FromQueue,
  65.                         LABT_ReturnKey,    TRUE,
  66.                         LA_ID,        UPLOAD_DUMMY,
  67.                     TAG_DONE);
  68.  
  69.                     LT_New(Handle,
  70.                         LA_Type,    XBAR_KIND,
  71.                         LAXB_FullSize,    TRUE,
  72.                     TAG_DONE);
  73.  
  74.                     LT_EndGroup(Handle);
  75.                 }
  76.             }
  77.  
  78.             LT_New(Handle,LA_Type,HORIZONTAL_KIND,
  79.                 LAGR_SameSize,    TRUE,
  80.                 LAGR_Spread,    TRUE,
  81.             TAG_DONE);
  82.             {
  83.                 LT_New(Handle,
  84.                     LA_Type,    BUTTON_KIND,
  85.                     LA_LabelID,    MSG_UPLOADPANEL_IGNORE_GAD,
  86.                     LA_ID,        UPLOAD_IGNORE,
  87.                     LABT_ExtraFat,    TRUE,
  88.                 TAG_DONE);
  89.  
  90.                 LT_New(Handle,
  91.                     LA_Type,    BUTTON_KIND,
  92.                     LA_LabelID,    MSG_GLOBAL_ABORT_GAD,
  93.                     LA_ID,        UPLOAD_ABORT,
  94.                     LABT_EscKey,    TRUE,
  95.                     LABT_ExtraFat,    TRUE,
  96.                 TAG_DONE);
  97.  
  98.                 LT_EndGroup(Handle);
  99.             }
  100.  
  101.             LT_EndGroup(Handle);
  102.         }
  103.  
  104.         if(PanelWindow = LT_Build(Handle,
  105.             LAWN_TitleID,        MSG_UPLOADPANEL_TRANSFER_TYPE_TXT,
  106.             LAWN_IDCMP,        IDCMP_CLOSEWINDOW,
  107.             LAWN_HelpHook,        &GuideHook,
  108.             LAWN_Parent,        Window,
  109.             WA_DepthGadget,        TRUE,
  110.             WA_CloseGadget,        TRUE,
  111.             WA_DragBar,        TRUE,
  112.             WA_RMBTrap,        TRUE,
  113.             WA_Activate,        TRUE,
  114.         TAG_DONE))
  115.         {
  116.             struct IntuiMessage    *Message;
  117.             BOOLEAN             Done = FALSE;
  118.             ULONG             MsgClass,
  119.                          MsgQualifier;
  120.             UWORD             MsgCode;
  121.             struct Gadget        *MsgGadget;
  122.  
  123.             GuideContext(CONTEXT_TRANSFER);
  124.  
  125.             PushWindow(PanelWindow);
  126.  
  127.             LT_ShowWindow(Handle,TRUE);
  128.  
  129.             do
  130.             {
  131.                 if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
  132.                 {
  133.                     Selection = UPLOAD_ABORT;
  134.  
  135.                     break;
  136.                 }
  137.  
  138.                 while(Message = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort))
  139.                 {
  140.                     MsgClass    = Message -> Class;
  141.                     MsgQualifier    = Message -> Qualifier;
  142.                     MsgCode        = Message -> Code;
  143.                     MsgGadget    = (struct Gadget *)Message -> IAddress;
  144.  
  145.                     GT_ReplyIMsg(Message);
  146.  
  147.                     LT_HandleInput(Handle,MsgQualifier,&MsgClass,&MsgCode,&MsgGadget);
  148.  
  149.                     if(MsgClass == IDCMP_CLOSEWINDOW)
  150.                     {
  151.                         Selection = UPLOAD_ABORT;
  152.  
  153.                         Done = TRUE;
  154.                     }
  155.  
  156.                     if(MsgClass == IDCMP_GADGETUP)
  157.                     {
  158.                         switch(MsgGadget -> GadgetID)
  159.                         {
  160.                             case UPLOAD_TEXT:
  161.  
  162.                                 if(FromQueue && !CheckUpload())
  163.                                     FromQueue = FALSE;
  164.  
  165.                                 if(FromQueue)
  166.                                     Selection = UPLOAD_TEXT_FROM_LIST;
  167.                                 else
  168.                                     Selection = UPLOAD_TEXT;
  169.  
  170.                                 Done = TRUE;
  171.  
  172.                                 break;
  173.  
  174.                             case UPLOAD_BINARY:
  175.  
  176.                                 if(FromQueue && !CheckUpload())
  177.                                     FromQueue = FALSE;
  178.  
  179.                                 if(FromQueue)
  180.                                     Selection = UPLOAD_BINARY_FROM_LIST;
  181.                                 else
  182.                                     Selection = UPLOAD_BINARY;
  183.  
  184.                                 Done = TRUE;
  185.  
  186.                                 break;
  187.  
  188.                             default:
  189.  
  190.                                 if(MsgGadget -> GadgetID != UPLOAD_DUMMY)
  191.                                 {
  192.                                     Selection = MsgGadget -> GadgetID;
  193.  
  194.                                     Done = TRUE;
  195.                                 }
  196.  
  197.                                 break;
  198.                         }
  199.                     }
  200.                 }
  201.             }
  202.             while(!Done);
  203.  
  204.             PopWindow();
  205.         }
  206.  
  207.         LT_DeleteHandle(Handle);
  208.     }
  209.  
  210.     return(Selection);
  211. }
  212.